﻿// <copyright file="AddInExportDefinition.cs" company="Anatoly Sereda">
// © 2009 Anatoly Sereda
//
// This source is subject to the Microsoft Public License.
// Please see the License.txt file for more information.
// All other rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// </copyright>
// <author>Anatoly Sereda</author>
// <email>neonnvr@live.com</email>
// <date>2009-08-04</date>

using System.AddIn.Hosting;
using System.Collections.Generic;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Primitives;

namespace MafMefInterop
{
	public class AddInExportDefinition : ExportDefinition, ICompositionElement
	{
		private AddInComposablePartDefinition definition;

		internal AddInExportDefinition(AddInComposablePartDefinition definition)
		{
			this.definition = definition;
		}

		public override string ContractName
		{
			get
			{
				return this.definition.ContractType.FullName;
			}
		}

		public override IDictionary<string, object> Metadata
		{
			get
			{
				Dictionary<string, object> metadata = new Dictionary<string, object>();
				metadata.Add(CompositionConstants.ExportTypeIdentityMetadataName, this.ContractName);
				foreach (QualificationDataItem item in this.definition.AddInToken)
				{
					metadata.Add(item.Name, item.Value);
				}

				return metadata;
			}
		}

		public string DisplayName
		{
			get { return null; }
		}

		public ICompositionElement Origin
		{
			get { return this.definition; }
		}
	}
}
